//
//  NewsTableView.m
//  Mtime2.0
//
//  Created by 凉气的Mac on 16/9/20.
//  Copyright © 2016年 凉气的Mac. All rights reserved.
//

#import "NewsTableView.h"

#import "NewsHeaderView.h"

#import "NewsTableViewCell.h"

#import "NewsTableViewCell1.h"

#import "NewsTableViewCell2.h"

static NSString *reuserId = @"news";

@interface NewsTableView ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation NewsTableView



-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        //设置界面
        [self setupUI];
        
    }
    return self;
}

#pragma mark --
#pragma mark --设置界面
-(void)setupUI{
    
    NewsHeaderView *headerView = [[NewsHeaderView alloc]initWithFrame:CGRectMake(0, 0, 0, 200)];
    
    self.tableHeaderView = headerView;
    
    self.delegate = self;
    
    self.dataSource = self;
    
    [self registerClass:[NewsTableViewCell class] forCellReuseIdentifier:@"cell"];
    
    [self registerClass:[NewsTableViewCell1 class] forCellReuseIdentifier:@"cell1"];
    
    [self registerClass:[NewsTableViewCell2 class] forCellReuseIdentifier:@"cell2"];
    
    self.rowHeight = UITableViewAutomaticDimension;
    
    self.estimatedRowHeight = 100;
    
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 2;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    if (section == 0) {
        
        return 1;
        
    }
    
    return 10;

}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    NewsTableViewCell1 *cell = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
    
    if (indexPath.row > 6) {
        cell = [tableView dequeueReusableCellWithIdentifier:@"cell2"];
    }
    
    if (indexPath.section == 0) {
        
        cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        
    }
    
    return cell;

}



-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    return 0.1;

}

@end




















